package com.zimin.cloud.user.biz.impl;

import com.aliyuncs.auth.AuthConstant;
import com.zimin.cloud.mine.pojo.user.view.UserRoleVO;
import com.zimin.cloud.user.biz.IAuthRoleBiz;
import com.zimin.cloud.user.pojo.entity.AuthRole;
import com.zimin.cloud.user.pojo.entity.UserRole;
import com.zimin.cloud.user.pojo.view.UserAuthorities;
import com.zimin.common.annotation.Biz;
import com.zimin.cloud.user.biz.IUserRoleBiz;
import com.zimin.cloud.user.service.impl.UserRoleServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.stream.Collectors;


/**
 * <p>
 * 用户角色关联表 业务对象
 * </p>
 *
 * @author zimin
 * @since 2022-06-14 15:53
 */
@Biz("userRoleBiz")
public class UserRoleBizImpl extends UserRoleServiceImpl implements IUserRoleBiz {

    @Autowired
    private IAuthRoleBiz authRoleBiz;

    @Override
    public UserAuthorities getUserAuthorities(String userId) {
        var userRoleList = super.getUserRoleByUserId(userId);
        var roleIdSet = userRoleList.stream().map(UserRoleVO::getRoleId).collect(Collectors.toSet());
        var roleElementOperationList = authRoleBiz.getRoleElementOperationList(roleIdSet);
        return null;
    }

    @Override
    public void addUserDefaultUser(String id) {
        var userRole = new UserRole();
        var role = authRoleBiz.getRoleByCode("0");
        userRole.setUserId(id);

    }
}
